package com.example.selenium;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ConfigurableApplicationContext;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by skyair on 2021/8/5
 */
public class Tester {
     public  static void main(String[]args){
         String jsonString = readFileContent("E:\\未支付0701-0806.txt");
         JSONArray jsonObjects = JSONObject.parseObject(jsonString).getJSONArray("data");
         List<String> pros = new ArrayList<>();
         for (int i = 0 ; i<jsonObjects.size();i++){

             JSONObject jo = jsonObjects.getJSONObject(i);
             JSONObject op =  jo.getJSONArray("wayBillOperateStatuses").getJSONObject(0);
               System.out.println(jo.getInteger("waybillId")+"\t"+jo.getString("waybillNo")+"\t"+op.getInteger("createdUserId")+"\t"+op.getString("createdUserNickname")+"\t"+jo.getString("driverId"));
                String pro =  jo.getString("projectId")+"\t"+jo.getString("projectName")+"\t"+op.getInteger("createdUserId")+"\t"+op.getString("createdUserNickname");
                if(!pros.contains(pro)){
                    pros.add(pro);
                }
//             System.out.println("   INSERT INTO `tpl_db`.`t_transportation_project`(`id`, `project_name`, `project_abbreviation`, `described`, `project_state`, `create_time`, `update_time`, `user_id`, `ent_id`) VALUES ("+jo.getInteger("id")+", '"+jo.getString("projectName")+"', '"+jo.getString("projectsImpName")+"', '"+jo.getString("projectsImpName")+"', 'ENABLE', '2020-09-15 21:29:16', NULL, "+jo.getInteger("creater")+", 100186);");
         }



         for(String o : pros){
        //     System.err.println(o);
         }




    }


    public static String readFileContent(String fileName) {
        File file = new File(fileName);
        BufferedReader reader = null;
        StringBuffer sbf = new StringBuffer();
        try {
            reader = new BufferedReader(new FileReader(file));
            String tempStr;
            while ((tempStr = reader.readLine()) != null) {
                sbf.append(tempStr);
            }
            reader.close();
            return sbf.toString();
        } catch ( Exception e) {
            e.printStackTrace();
        } finally {
            if (reader != null) {
                try {
                    reader.close();
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
        }
        return sbf.toString();
    }
}

